package com.dkm.ec.product.domain;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;

import com.dkm.base.api.service.IdGenerator;
import com.dkm.base.core.helper.SpringHelper;
import com.dkm.biz.domain.AbstractDomain;
import com.dkm.ec.product.persistence.dao.ProdRelDao;
import com.dkm.ec.product.persistence.entity.ProdRelPo;

/**
 * 对象功能:产品关联 领域对象实体
 * 开发公司:SKG.COM
 * 开发人员:Yuki
 * 创建时间:2014-12-25 09:39:25
 */
@Service
@Scope("prototype")
public class ProdRel extends AbstractDomain<String, ProdRelPo>{
	 
	 private ProdRelDao prodRelDao = null;
	 private IdGenerator idGenerator = null;

	protected void init(){
		prodRelDao = SpringHelper.getBean(ProdRelDao.class);
		idGenerator = SpringHelper.getBean(IdGenerator.class);
		setDao(prodRelDao);
	}	 
	 
/*	public void saveRelForWhole(List<HomeEntityPo> homeEntityPos,String productId,String relType) {
		init();
		//先删除旧的媒体
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("mainId", productId);
		prodRelDao.deleteByKey("deleteByMainId", params);
		
		String homeMediaId = "";
		
		//再保存一次
		if(homeEntityPos!=null){
			int i=0;
			for(HomeEntityPo homeEntityPo:homeEntityPos){
				ProdRelPo prodRelPo = new ProdRelPo();
				prodRelPo.setId(idGenerator.genSid());
				prodRelPo.setMainId(productId);
				prodRelPo.setRelId(homeEntityPo.getId());
				prodRelPo.setRelType(relType);
				prodRelPo.setSort(i);
				i++;
				prodRelDao.create(prodRelPo);
			}
		}
	}*/
}
